package com.ruoyi.web.service.impl;

import java.util.List;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.mapper.DrugDiseaseMapper;
import com.ruoyi.web.domain.DrugDisease;
import com.ruoyi.web.service.IDrugDiseaseService;
import com.ruoyi.common.core.text.Convert;

/**
 * 药品疾病关联（新）Service业务层处理
 * 
 * @author drx
 * @date 2024-03-11
 */
@Service
public class DrugDiseaseServiceImpl implements IDrugDiseaseService 
{
    @Autowired
    private DrugDiseaseMapper drugDiseaseMapper;

    /**
     * 查询药品疾病关联（新）
     * 
     * @param id 药品疾病关联（新）主键
     * @return 药品疾病关联（新）
     */
    @Override
    public DrugDisease selectDrugDiseaseById(Long id)
    {
        return drugDiseaseMapper.selectDrugDiseaseById(id);
    }

    /**
     * 查询药品疾病关联（新）列表
     * 
     * @param drugDisease 药品疾病关联（新）
     * @return 药品疾病关联（新）
     */
    @Override
    public List<DrugDisease> selectDrugDiseaseList(DrugDisease drugDisease)
    {
        return drugDiseaseMapper.selectDrugDiseaseList(drugDisease);
    }

    /**
     * 新增药品疾病关联（新）
     * 
     * @param drugDisease 药品疾病关联（新）
     * @return 结果
     */
    @Override
    public int insertDrugDisease(DrugDisease drugDisease)
    {
        drugDisease.setCreateTime(DateUtils.getNowDate());
        drugDisease.setCreateBy(ShiroUtils.getSysUser().getLoginName());
        drugDisease.setCreateName(ShiroUtils.getSysUser().getUserName());
        return drugDiseaseMapper.insertDrugDisease(drugDisease);
    }

    /**
     * 修改药品疾病关联（新）
     * 
     * @param drugDisease 药品疾病关联（新）
     * @return 结果
     */
    @Override
    public int updateDrugDisease(DrugDisease drugDisease)
    {
        drugDisease.setUpdateTime(DateUtils.getNowDate());
        drugDisease.setUpdateBy(ShiroUtils.getSysUser().getLoginName());
        return drugDiseaseMapper.updateDrugDisease(drugDisease);
    }

    /**
     * 批量删除药品疾病关联（新）
     * 
     * @param ids 需要删除的药品疾病关联（新）主键
     * @return 结果
     */
    @Override
    public int deleteDrugDiseaseByIds(String ids)
    {
        return drugDiseaseMapper.deleteDrugDiseaseByIds(Convert.toStrArray(ids),ShiroUtils.getSysUser().getLoginName());
    }

    /**
     * 删除药品疾病关联（新）信息
     * 
     * @param id 药品疾病关联（新）主键
     * @return 结果
     */
    @Override
    public int deleteDrugDiseaseById(Long id)
    {
        return drugDiseaseMapper.deleteDrugDiseaseById(id,ShiroUtils.getSysUser().getLoginName());
    }

    /**
     * 删除药品疾病关联信息
     *
     * @param drugId 药品疾病关联主键
     * @return 结果
     */
    public int deleteDrugDiseaseByDrugId(Long drugId)
    {
        return drugDiseaseMapper.deleteDrugDiseaseByDrugId(drugId,ShiroUtils.getSysUser().getLoginName());
    }
}
